package com.gw.detail.controllor.detail;

import java.util.List;

import com.gw.detail.domain.Befrag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.gw.detail.service.IBefragService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 回访数据Controller
 * 
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/befrag")
public class BefragController extends BaseController
{
    @Autowired
    private IBefragService befragService;

    /**
     * 查询回访数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:befrag:list')")
    @GetMapping("/list")
    public TableDataInfo list(Befrag befrag)
    {
        startPage();
        List<Befrag> list = befragService.selectBefragList(befrag);
        return getDataTable(list);
    }

    /**
     * 导出回访数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:befrag:export')")
    @Log(title = "回访数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Befrag befrag)
    {
        List<Befrag> list = befragService.selectBefragList(befrag);
        ExcelUtil<Befrag> util = new ExcelUtil<Befrag>(Befrag.class);
        return util.exportExcel(list, "回访数据数据");
    }

    /**
     * 获取回访数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:befrag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(befragService.selectBefragById(id));
    }

    /**
     * 新增回访数据
     */
    @PreAuthorize("@ss.hasPermi('detail:befrag:add')")
    @Log(title = "回访数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Befrag befrag)
    {
        return toAjax(befragService.insertBefrag(befrag));
    }

    /**
     * 修改回访数据
     */
    @PreAuthorize("@ss.hasPermi('detail:befrag:edit')")
    @Log(title = "回访数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Befrag befrag)
    {
        return toAjax(befragService.updateBefrag(befrag));
    }

    /**
     * 删除回访数据
     */
    @PreAuthorize("@ss.hasPermi('detail:befrag:remove')")
    @Log(title = "回访数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(befragService.deleteBefragByIds(ids));
    }
}
